home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-13 / amac44d.zip / SM.QM < prev    next >
Text File  |  1992-05-27  |  17KB  |  380 lines

  1. *                              SM.QM, ver P
  2. *                 Search From Command Line With MaxFind
  3. *                                 5/30/92
  4. *                        Written by Tom Hogshead
  5. *
  6. *   @6  Search From Command Line, Load Files w/Search Text (Must Use SM.BAT)
  7. *
  8. *   f4  Finds search text in file after loading
  9. *   f5  PrevFile
  10. *   f6  NextFile
  11. *
  12. *   @h  Jump To Macro or Index Item
  13. *
  14. *   Description
  15. *   Syntax
  16. *   Mode
  17. *   Required
  18. *   Options - MaxFind
  19. *   Note
  20. *   Examples
  21. *   Index use with @h
  22. *   PCED synonymns to search from a file list
  23. *   Other macros:
  24. *   Environment Variables - See SRCHxx.QM for discussion
  25. *   Required Program Files
  26. *   CAUTION <<<<<
  27. *   Version history
  28. *
  29. *--eoi
  30.  
  31.  
  32. * (DESCRIPTION)
  33. * --------------
  34. * SM.QM are QEdit macros to search files containing a search string using
  35. * MaxFind. Files are searched, found, and loaded for editing or viewing.
  36. * The search string, file names, and other input or search options may be
  37. * specified at the command line or entered at the option query prompt.
  38. * "Fuzzy", "and/or", and "sliding window" text searches can be done.
  39. *
  40. * To run, type "sm" <enter>, and answer the prompts. Press F4 to
  41. * view the search string in each file after finding. Alternatively,
  42. * parameters may be specified at the command line.
  43.  
  44. * 1) SYNTAX:                           SM.BAT %1 %2 %3
  45. *                                   ┌──────────┘  │  └───────────┐
  46. *              (Mode)              %1            %2             %3
  47. *                             Search Text     File Name       Option
  48. *          ----------------   -------------   ----------      -------
  49. *       a) Query              <------- all inputs at prompts ------->
  50. *       b) Partial Query      Search Text        [ ]            [ ]
  51. *       c) Partial Query      Search Text        [ ]          default
  52. *       d) Command line       Search Text     File Name       default
  53. *       e) All command line   Search Text     File Name         [ ]
  54. *
  55. *          where:    %1  - Search Text
  56. *                    %2  - File Name, wild cards OK
  57. *                    %3  - MAXFIND options entered without minus
  58. *                    [ ] - entered at query prompt
  59. * 2) Requires MAXFIND MF.EXE and INPUT.COM
  60. * 3) File Name wild cards OK.
  61. * 4) MAXFIND options can be input at option prompt or %3, default option "ltn"
  62. * 5) Set environment variable OPT=off to bypass MAXFIND option query prompt
  63. *
  64.  
  65. * MAXFIND (OPTIONS):
  66. *
  67. *  MaxFind. Version 2.3   Copyright 1988,90 by Stan Peters
  68. *            Shareware, $15.       Box 2028, Fairfield, Iowa 94306
  69. *   Usage:  mf  [-options] string  [string].... filename [-options]
  70. *         Filename may contain ? and *, it may have a path prefix
  71. *         You may have 1 to 15 strings.
  72. *         A tilde (~) in a string matches any character.
  73. *         Options must start with a '- ', they may be first and/or last.
  74. *     Searching options:
  75. *        a - 'and', all must be present.  f - "fuzzy", approximate spelling.
  76. *        c - case sensitive search.       w - match only if a word.
  77. *        d - Span entire document, if necessary.
  78. *     Output options:
  79. *        l - show line numbers.      (*)   t - to screen and > file.    (*)
  80. *        m - stop after first match. (*)   u - Unix (grep) style output.(*)
  81. *        n - no pause each 24 lines. (*)
  82. *     Input options:
  83. *        b - also search binary files.    s - also include subdirectorys
  84. *        h - strip hi (8) bits.
  85. *     AND searches using "sliding windows":
  86. *        2 - 15  Window size (number of lines) for searching and displaying
  87. *
  88. *         afcwdbsh/ - OK with SM
  89. *
  90. *  A  /  indicates an OR within an AND, use  //  to find  / .
  91. *     Example:  Find Tom or Bob Jones from Texas in my address file
  92. *     Enter:   "mf  tom/bob jones texas  address.fil  -a4"
  93. *
  94. *     (*) - do not use with sm.bat, "ntl" are default options with sm.bat
  95.  
  96. * (NOTE)
  97. * -------
  98. *     - @6 must be the first macro in this file to be used with sm.bat.
  99. *     - To use this macro in any directory, change /Esm.mac and
  100. *       /Lsm.mac in sm.bat to the location of sm.mac, eg change to
  101. *       /Ee:\up\sm.mac.
  102. *     - Enter other search or input options as %3 or at the option,
  103. *       prompt, eg "c" for case sensitive search without the minus.
  104. *     - Search is case insensitive unless option "c" is specified.
  105. *     - If no files are found containing the search text, a message
  106. *       "No text found" is displayed.
  107. *     - Macro will stop before completion if any line containing the
  108. *       search text also contains "g>". Macro cannot search for "g>".
  109. *     - This macro can be quite "noisy" if beeps are set on with
  110. *       QCONFIG, especially if there are many lines containing
  111. *       search text. We use "Find" to check each line of the output
  112. *       to determine whether it is a file name or found text. File
  113. *       names are not quite as "noisy". Testing this macro has forced
  114. *       me to set QEdit beeps "off"!
  115. *     - A minimum of of 55 bytes free environment space is needed to
  116. *       search for a 10 character string with 12 character file spec
  117. *       and 1 character option. I suggest you have at least a 100
  118. *       bytes free to be safe. Since the free environment space is
  119. *       considerably reduced when "shelling to DOS", sm.bat may not
  120. *       work properly when "shelled" from another program.
  121. *     - MaxFind writes to disk at least once for every file it
  122. *       searches. Therefore, for faster macro operation, replace c:\
  123. *       in sm.bat and sm.qm with your ram drive.
  124.  
  125. * (EXAMPLES)
  126. * -----------
  127. *     a)  Example:  Load all files with extension "bat" or "tst"
  128. *                   containing "aaa"  and "bbb" in each file.
  129. *             (Must be run from input mode because of %1 %2 %3 defs.)
  130. *         Enter:    "sm" <enter>, and at the query prompts enter...
  131. *                         Search text   =aaa bbb
  132. *                         File name(s)  =*.??t
  133. *                         Option(s)     =
  134. *
  135. *     b)  Example:  Load all files with extension "tst" containing "ccc"
  136. *         Enter:   "sm ccc *.tst" <enter>
  137.  
  138. *     c)  Example:  Load all files containing "ddd" and "eee" only
  139. *                   within a 2 line window in each file, with extension
  140. *                   "tst".
  141. *                (Must be run from input mode because of %1 %2 %3 defs.)
  142. *         Enter:    "sm" <enter>, and at the query prompts enter...
  143. *                         Search text   =ddd eee
  144. *                         File name(s)  =*.tst
  145. *                         Option(s)     =a2
  146. *                   (sm.tst is included to test above examples)
  147.  
  148. * (INDEX) USE
  149. * -----------
  150. * To locate a macro or item in this file, press @h, place the cursor
  151. * line on the desired item in the Index above, and press <enter>.
  152. * See BOOKxx.QM for more details.
  153.  
  154.  
  155. * (PCED) Synonymns To Search From A File List
  156. * --------------------------------------------
  157. * MaxFind does not have the option of searching from a file list.
  158. * However PCED by Chris Dunford with the following synonyms using the
  159. * "@@file list" option will search from the file list "sm.lst".
  160. *
  161. * rem PCED synonyms for MaxFind Search, Syntax: SMC1 [search text]
  162. *
  163. *     SYN smc1     'cef^cancel &A^delc^mfc &A^qec^cen'
  164. *     SYN cancel   'if "&A" == "" CED CANCEL notxt'
  165. *     SYN notxt    'echo No search text, Syntax: SMC1 [search text]^cen'
  166. *     SYN cef      'CED ECHO OFF^echo off'
  167. *     SYN delc     'if exist c:\! del c:\!'
  168. *     SYN cen      'echo on^CED ECHO ON'
  169. *     SYN mfc      'mf.exe -ntl &A @@sm.lst>>c:\!'
  170. *     SYN qec      'q.exe c:\! /Esm.mac /Lsm.mac'
  171. * rem SYN mfc      'mf.exe -ntl &A @@e:\up\sm.lst>>c:\!'
  172. * rem SYN qec      'q.exe c:\! /Ee:\up\sm.mac /Le:\up\sm.mac'
  173.  
  174. * NOTE: Change "e:\up\" to the directory where sm.mac and sm.lst reside.
  175. * "REM" lines are my setup.
  176. *
  177. * You must have PCED v2.00 or later with the Filelist progam FL.EXE
  178. * loaded. These synonyms are in sm.sym and can be loaded with SM_SYN.bat
  179.  
  180. * File list sm.lst is only one line "*.tst" for testing. To test,
  181. * type "smc1 aaa" <enter> after loading these synonyms.
  182.  
  183.  
  184. * (OTHER) MACROS
  185. * ------------------
  186. * See SRCxxx.QM in AMACxx.Zip for search and search/replace macros using
  187. * Chris Dunford's excellent FGREP.COM.com.
  188.  
  189.  
  190. * >>>>>>> (CAUTION) <<<<<<<<
  191. *
  192. * Letters "S~~" and "R~~" must NOT occur in any other Dos environment
  193. * variable name or value.
  194. *
  195.  
  196. * (ENVIRONMENT) Variables - See SRCHxx.QM for discussion
  197.  
  198. * (REQUIRED) PROGRAM FILES
  199. * --------------------------
  200. * You──MUST──have the exectable program files in AMAC-PRG.ZIP to run
  201. * some of these macros. AMAC-PRG.ZIP can be found on the following BBS's:
  202. *
  203. *                                 SemWare
  204. *                                 Exec-PC
  205. *
  206. * It can not be found on CompuServe since many of the programs are
  207. * Copyrighted. All program files are ShareWare, and inclusion in
  208. * AMAC-PRG.ZIP is not prohibited in their documentation.
  209. *
  210. * MAXFND23.ZIP and INPUT.ZIP are the only files necessary to run SM.BAT.
  211. *
  212. * INPUT can be found on Exec-PC as INPUT.ZIP. MAXFIND v2.3 can be found
  213. * on CompuServe IBMSYS Lib 3 as MAXFND.ZIP and on EXec-PC as
  214. * MAXFND23.ZIP
  215. *
  216. * AMAC-PRG.ZIP contains:
  217. * ----------------------
  218. * Name          Length    Method     SF   Size now  Mod Date
  219. * ============  ========  ========  ====  ========  =========
  220. * INPUT.ZIP         3097   Stored     0       3097  07 May 86
  221. * MAXFND23.ZIP     24247   Stored     0      24247  26 Apr 90
  222. * RJ.ZIP            9965   Stored     0       9965  01 Dec 90
  223. * FGREP172.ZIP     12513   Stored     0      12513  19 May 90
  224. * DX211.ZIP       100895   Stored     0     100895  17 Mar 89
  225. * AMAC-PRG.INF      3138  Imploded   67       1014  23 Apr 91
  226. * ============  ========  ========  ====  ========  =========
  227. * *total     6    153855  ZIP 1.10    0%    152329  23 Apr 91
  228. *
  229. * I thank the authors for these excellent programs.
  230.  
  231. * 
  232. * ----------------------------------------------------------------------
  233. * @(6) - Srch ONLY from command line, loads files w/sm.bat, no replace
  234. * -------------------- uses MaxFind mf.exe -----------------------------
  235. *    >>> MUST BE THE FIRST MACRO IN THIS FILE TO BE USED WITH SM.BAT <<<
  236. *
  237. @6 macrobegin
  238.         altwordset                      * For all file names
  239.         begfile                         * Just in case!
  240. * ----------------- delete MaxFind Copyright header -----------------*
  241.  header:
  242.         find "xfind C" return return    * Find MaxFind header
  243.         jfalse end_header
  244.         delline                         * Delete it until no more
  245.         jump header
  246.  end_header:
  247. * --------- delete "Hex file skipped" message and file name ---------*
  248.         begfile                         * Back to tof
  249.  hex:
  250.         find "Hex file s" return return * Find "Hex file skipped" msg
  251.         jfalse end_hex
  252.         delline                         * Delete it until no more
  253.         cursorup                        * Move up to hex name
  254.         delline                         * Delete it
  255.         jump hex                        * And do until done
  256.  end_hex:
  257.         begfile                         * Back to tof
  258. * ------------------ delete file names with no text ------------------*
  259.  cleanup:
  260.         begline                         * Position for find
  261.         unmarkblock
  262.         markline markline               * Mark line to check if name
  263.         find "g>" return "L"  return    * Check if name
  264.         jtrue name                      * If name, check if next line
  265.                                         * is also name
  266.         cursordown                      *ELSE move down to next line
  267.         jfalse end_cleanup               * If can't move down, at eof
  268.         jump cleanup                    * Check this line if name
  269.  name:
  270.         cursordown                      * Is a file, move down to next
  271.                                         * line
  272.         jfalse delete                   * If can't move down, at eof
  273.                                         * and it's a name, go delete it
  274.         cursorright                     *ELSE put cursor on >
  275.         unmarkblock                     *
  276.         markcolumn                      * Begin mark
  277.         cursorleft                      * Move left one space
  278.         markcolumn                      * Mark column to check for "g>"
  279.         cursorleft                      * Move to "n" in "Searching"
  280.         find "g>" return "L"  return    * Is line a name?
  281.         jfalse cleanup                  * If not a name, go to cleanup
  282.         cursorup                        *ELSE must be text, move back
  283.                                         * up to where we were
  284.         jfalse end_cleanup              * If can't move up, at tof
  285.         delline                         *ELSE Delete name with no text
  286.         jump cleanup
  287.  delete:
  288.         delline                         * Delete last line if name
  289.  end_cleanup:
  290. * -------------------- load file names with text --------------------*
  291.         endfile                         * Start to load at eof
  292.  load:
  293.         begline                         * Position for find
  294.         find "g>" return "B"  return    * Find line with file name
  295.         jfalse text                     * No more file names? Move up
  296.         wordright *wordright wordright  * Move to file name
  297.         unmarkblock                     * Clear last mark
  298.         markcolumn                      * And begin mark
  299.         endline                         * Get all name in block
  300.         copy                            * Copy file name to scrap
  301.         EditFile                        * Get ready to load
  302.         CurrentFilename " "             * To force return *here*
  303.         Paste Return                    * Paste file name & do it!
  304.  text:
  305.         cursorup                        * Go to next line
  306.         jfalse end_load                 * No more file names? End load
  307.         jump load                       *ELSE more files to load
  308.  end_load:
  309. * --------------------- "No found text" message ---------------------*
  310.         cursordown cursorup             * Test if any search text found
  311.         jtrue find_set                  * If found, move on
  312.         "No found text "                *ELSE no find, display this
  313.         jump end                        * End macro if no found text
  314.  find_set:
  315. * -------------------- initialize find for search --------------------*
  316.         editfile "c:\$" return          * Load tempfile
  317.         find  "S~~" return return      ** Find S~~ in SET output
  318.         find "=" return return          * Move to =
  319.         cursorright                     * Move first character
  320.         markcharacter                   * Mark it
  321.         endline                         * Move to end of text
  322.         copy                            * Copy search text to scrap
  323.         killfile quit                   * Kill/quit temp for next time
  324.         Find paste return Escape        * Initialize find for F4
  325. * ------------------------------ reset ------------------------------*
  326.  end: defaultwordset                    * Reset
  327. *
  328. * 233 bytes Wed  04-17-1991  16:35:04
  329. * 216 bytes Wed  04-24-1991  14:18:01 moved DOS "set>c:$" to SM.BAT
  330. *                                     replace R~~ with S~~
  331. * 221 bytes Tue  04-30-1991  22:28:02 changed initialize find routine
  332.  
  333.  
  334. * 
  335. * (f4) Finds search text in file after loading
  336. f4 repeatfind
  337.  
  338. * 
  339. * (f5) prevfile
  340. *
  341. f5 prevfile
  342.  
  343. * 
  344. * (f6) nextfile
  345. f6 nextfile
  346.  
  347. * 
  348. * ----------------------------------------------------------------------
  349. * @(h) Finds first word on cursor line marked in document below
  350. * ----------------------------------------------------------------------
  351. * Press @ and h at the same time. Cursor down to desired line in Index.
  352. * Press <enter> to locate the desired item from the Index. See
  353. * Bookxx.Qm in AMACxx.Zip for more discussion.
  354. *
  355. @h macrobegin
  356.         begfile
  357.         unmarkblock
  358.         markline markline
  359.         pause
  360.         wordright
  361.         markword
  362.         copy
  363.         endpara
  364.         find "(" paste ")"  return return
  365.         begline
  366. *
  367. * 22 bytes Tue  04-09-1991  16:23:53
  368.  
  369. * (Version) History
  370. * ------------------
  371. *   M   -   Changed SRCHxx version from 2.9 to 3.0.                     8/6/91
  372. *   N   -   Changed SM-SYN.BAT name to SM_SYN.BAT.                     8/26/91
  373. *   O   -   Modified documentation in this file.                       5/22/92
  374. *       -   In Amac43.zip.                                             5/27/92
  375. *   P   -   Added ( ) to Index line 1 for bok001.qm macros.            5/30/92
  376. *
  377. *
  378. *
  379. *--eof
  380.